﻿package com._public._control {
	import com._public._net.*;
	
	import flash.events.*;
	import flash.ui.*;
	/**
	 * ...
	 * @author wmy
	 * 
	 * 右键版权类
	 */
	//例子:
	/*
	new Copyright(this,"xxxxxx","http://www.xxxxx.com/");
	*/
	public class Copyright{
		private var _Root:Object;
		//右键菜单
		private var _contextMenu:ContextMenu;
		private var _contextMenuItem:ContextMenuItem;
		private var _name:String;
		private var _url:String;
		
		public function Copyright(Root:Object,na:String=null,url:String=null):void{
			_Root=Root;
			_name=na;
			_url=url;
			//初始菜单
			initCopyrightFn();
		}
		private function initCopyrightFn():void{
			_contextMenu= new ContextMenu();
			_contextMenu.hideBuiltInItems();
			_Root.contextMenu=_contextMenu;
			//添加名子
			if(_name!=null && !isBlank(_name)){
				_contextMenuItem = new ContextMenuItem(_name);
				_contextMenuItem.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,onMenuItemSelect);
				_contextMenu.customItems.push(_contextMenuItem);
			}
		}
		private function onMenuItemSelect(e:ContextMenuEvent):void{
			if(_url!=null && !isBlank(_url)){
				new GetUrl(_url);
			}
		}
		//是否空白
		private function isBlank (source:String):Boolean {
			for(var i:uint = 0; i<source.length;i++){
				if(source.charAt(i) != " "){
					return false
				}
			}
			return true
		}
	}
}